package taewanme.gae.bookmark.service;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import taewanme.gae.bookmark.dao.UserDaoJDOImpl;
import taewanme.gae.bookmark.model.User;

@Component("userService")
public class UserServiceImpl {

	@Resource
	private UserDaoJDOImpl userDao;
	
	public boolean authenticate(String email, String inputPass){
		User user = userDao.get(email);
		
		if(user==null) return false;
		
		String userPsswd = user.getPassword();
		
		if(userPsswd!=null&userPsswd.equals(inputPass)) return true;
		
		return false;
	}
		
	public boolean registerUser(User user){
		User registeredUser = userDao.save(user);
		return registeredUser!=null?true:false;
	}
	
	public User getUser(String email){
		return userDao.get(email);
	}
}
